package com.zhongjian.technologycal.mall.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.squareup.picasso.Picasso;
import com.zhongjian.technologycal.mall.R;
import com.zhongjian.technologycal.mall.base.BaseContacts;
import com.zhongjian.technologycal.mall.bean.MyCourseBean;

import java.util.List;

/**
 * Created by wei on 2018/4/8.
 */

public class CourseListAdapter extends BaseQuickAdapter<MyCourseBean, BaseViewHolder> {

    public CourseListAdapter(List data) {
        super(R.layout.items_course_list, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final MyCourseBean item) {
        if (item == null) {
            return;
        }
        helper.setText(R.id.course_order_tv_shopping_name, item.getCoursename());
        helper.setText(R.id.course_order_tv_shopping_content, item.getCoursebrief());
        helper.setText(R.id.course_order_tv_shopping_price, "" + item.getCourseprice());

        if(item.getCoursePhotos().size() > 0){
            Picasso.get().load(BaseContacts.BASE_URL + item.getCoursePhotos().get(0).getPhoto())
                .into((ImageView) helper.getView(R.id.course_order_iv_shopping_photo));



        }
        String status = "";
        if (item.getCurstatus() == 0) {//未开始
            status = "待开课";
        } else if (item.getCurstatus() == 1) {//开始
            status = "进行中";
        } else if (item.getCurstatus() == -2) {//结束
            status = "已结束";
        }
        helper.setText(R.id.course_order_tv_shopping_status, "" + status);

    }

}
